/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package wcb;

import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;



public class BD {

static Connection con;

     public void conectar() throws SQLException
    {
        try {
            Class.forName("com.mysql.jdbc.Driver");
            String conec = "jdbc:mysql://localhost/mydb?" +
                                   "user=root&password=12345678";
            con = DriverManager.getConnection(conec);
            Statement st = con.createStatement();
            ResultSet rs = st.executeQuery("Select * from Copa");
            int i = 0;
            int x; int y;
            String z; String w;
            while (rs.next()) {
                i++;
                x = rs.getInt(i);
                y = rs.getInt(i+1);
                z = rs.getString(i+2);
                w = rs.getString(i+3);
                System.out.print(x+" ");
                System.out.print(y+" ");
                System.out.print(z+" ");
                System.out.println(w);
                i=0;
}
        }   catch (ClassNotFoundException ex) {
            Logger.getLogger(BD.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}
